set more off

** cd [insert path] 

use "linked_outgroup_2024.dta"

gen control=1 if treatment==9
replace control=0 if inrange(treatment, 1, 8)

* "Respondents were asked a series of questions about their political views before they 
* were randomly assigned to a crisis vignette condition (n=6213) or a control condition (n=839). 
count if inrange(treatment, 1,8)
count if treatment==9

*"...among non-Muslim respondents (n=6122; 86.8% of our sample)"
fre muslim

* Of non-Muslim respondents, 39.4% expressed unwillingness to have a Muslim neighbor 
* with another 4.4% of respondents that “can’t say.” 
fre T9OM1A if T9OM1A!=.

* When asked if India’s Muslim population is growing too rapidly, 80.7% of non-Muslim 
* respondents agreed, while another 9.4% “can’t say.”
fre T9OM2 if T9OM2!=.

* Of non-Muslim respondents who were exposed to crisis vignettes involving China or Pakistan, 
* 38.8% stated they were unwilling to have a Muslim neighbor, 4.7 percentage points (p<0.05) 
* less than the 43.5% of respondents in the control condition that expressed this discriminatory view
ttest no_neighbor, by(control) uneq

* (Attitudes toward Muslim population growth were indistinguishable between crisis vignette and control conditions.) 
ttest muslim_rapid, by(control) uneq
ttest muslim_rapid, by(pakistan) uneq
ttest muslim_rapid if treatment!=9, by(pakistan) uneq

* 36.7% of respondents that received a crisis vignette involving Pakistan said they would not 
* be willing to have a Muslim neighbor compared to 41.4% of respondents receiving either China 
* vignettes or the control condition, a difference in means of 4.7 percentage points 
* (p<0.001 from a two-sided t-test permitting unequal variances).
ttest no_neighbor, by(pakistan) uneq

* The difference in means is 4.2 percentage points (p<0.01) between Pakistan and China vignette 
* conditions, excluding the control condition.
ttest no_neighbor if treatment!=9, by(pakistan) uneq


** Figure 1
gen hypo_groups=.
* Group All Pakistan Vignettes Under Hypo_Group 1
replace hypo_groups=1 if inlist(treatment, 2, 4, 6, 8)
* Group All China Vignettes Under Hypo_Group 2
replace hypo_groups=2 if inlist(treatment, 1, 3, 5, 7)
* Control Vignette is Hypo Group 3
replace hypo_groups=3 if treatment==9
reg no_neighbor ibn.hypo_groups, nocons 
est store A
coefplot A, vert mlabel format(%9.3g) scheme(s1mono)
graph save Graph "figure1.gph", replace

* Sub-group tests
reg no_neighbor pakistan##modi_dummy
reg no_neighbor pakistan##bjp_dummy
reg no_neighbor pakistan##high_inc
reg no_neighbor pakistan##moremuslims
reg no_neighbor pakistan##old
reg no_neighbor pakistan##north_south
reg no_neighbor pakistan##gender

* "Muslim respondents professing unwillingness to have a Hindu neighbor were rare. 
* In all non-Pakistan vignettes and the control, they constituted 3.8% of Muslim 
* respondents. In Pakistan vignette arms, they constituted just 1.5%, for a 2.4 
* percentage point difference in means (p<0.05)."

ttest no_hindu_neigh, by(pakistan) uneq


*** APPENDIX
log using "linked_outgroup_appendix.smcl", replace

** Appendix A3
* Table A3
fre treatment

* Table A4
sum muslim gender rural age bjp_dummy 

* A6
* Table A6
ttesttable muslim treatment, unequal ref(1)
ttesttable gender treatment, unequal ref(1)
ttesttable age treatment, unequal ref(1)
ttesttable rural treatment, unequal ref(1)
ttesttable bjp_dummy treatment, unequal ref(1)
ttesttable high_inc treatment, unequal ref(1)
ttesttable high_educ treatment, unequal ref(1)

mlogit treatment muslim gender age rural bjp_dummy high_inc high_educ

* A7 Main Experimental Results
ttest no_neighbor, by(control) uneq
ttest no_neighbor, by(pakistan) uneq
ttest no_neighbor if treatment!=9, by(pakistan) uneq
ttest muslim_rapid, by(control) uneq
ttest muslim_rapid, by(pakistan) uneq
ttest muslim_rapid if treatment!=9, by(pakistan) uneq
ttest no_hindu_neigh, by(pakistan) uneq

* A8 Sub-Group Tests
reg no_neighbor pakistan##modi_dummy
reg no_neighbor pakistan##bjp_dummy
reg no_neighbor pakistan##high_inc
reg no_neighbor pakistan##moremuslimstate
reg no_neighbor pakistan##old
reg no_neighbor pakistan##north_south
reg no_neighbor pakistan##gender
reg no_neighbor pakistan##high_ed

* A9 Additional Outcome Measure: Reputational Spillover
gen figA1=1 if treatment==6|treatment==8
replace figA1=2 if treatment==2|treatment==4
replace figA1=3 if inlist(treatment, 1, 3, 5, 7)
replace figA1=4 if treatment==9
reg better_muslim ibn.figA1, nocons
est store B
coefplot B, vert mlabel format(%9.3g) scheme(s1mono)
graph save Graph "figureA1.gph", replace

test 1.figA1=2.figA1
test 1.figA1=3.figA1
test 1.figA1=4.figA1

ttest better_muslim, by(pak_counter) uneq

log close

